/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using System.Collections.Generic;
using NetProtocol.POD;
using NetProtocol.Enum;
using IQIGame.Onigao.Game;
using IQIGame.Onigao.GamePlay;
using IQIGame.Onigao.Framework;
using Cysharp.Threading.Tasks;
using System;
using static IQIGame.Onigao.Game.MessageWrapper;

namespace NetProtocol.Client {
	/// <summary>
	/// 灵魂
	/// module : soul
	/// </summary>
	public interface CNetSoul : INetClientModule {
		
		public ISession GetSession();
	
		Dictionary<int, INetClientModule.Package2MessageWrapper> INetClientModule.GetModuleFunction()
        {
            MessageFunction notifySoulActive_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifySoulActiveData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.soul_notifySoulActive, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifySoulActive(session, _wrapper.message.soulPOD);
                MessageWrapperPool<NotifySoulActiveData>.Put(_wrapper);
            };
        
            Dictionary<int, INetClientModule.Package2MessageWrapper> retDic = new()
            {
                {NetMessageId.soul_notifySoulActive, (session, package) => {
                	var result = MessageWrapperPool<NotifySoulActiveData>.Get();
                	result.Init(session, notifySoulActive_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
            };
            return retDic;
        }
#region Client-side Interface
		/// <summary>
        ///  通知激活了灵魂
        /// </summary>
		protected void SC_notifySoulActive(ISession session, SoulPOD soulPOD);
#endregion
#region Server-side Interface
#endregion
#region Messages
        public struct NotifySoulActiveData : IReceiveMessage {
	        public SoulPOD soulPOD;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                soulPOD = _in.HasRemaining() ? _in.Read_pod<SoulPOD>(SoulPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.soul_notifySoulActive;}
            
            public override string ToString()
            {
                return "Soul.notifySoulActive"+ ", soulPOD="+ soulPOD;
            }
        }
    }
#endregion
}